package com.heartskyhigh.order.VO;

import com.heartskyhigh.order.enums.ResultEnum;
import lombok.Data;

/**
 * @author Luo Zhen
 * @create 2019-11-19 17:35
 */
@Data
public class ResultVO<T> {

    private Integer code;

    private String msg;

    private T data;

    public ResultVO() {

    }

    public ResultVO(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResultVO(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResultVO<T> ok(T object) {
        return new ResultVO<T>(ResultEnum.OK.getCode(), ResultEnum.OK.getMsg(), object);
    }

    public static <T> ResultVO<T> error(String msg, T data) {
        return new ResultVO<T>(ResultEnum.SERVER_ERROR.getCode(), msg, data);
    }


}
